package com.dongdongshop.data;

import com.dongdongshop.em.ConstantEnum;

import java.io.Serializable;

public class Result<T> implements Serializable {

    private Integer code; // 状态码
    private String message; //
    private T result; //
    private T rows; //
    private Long total; //


    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getResult() {
        return result;
    }

    public Result setResult(T result) {
        this.result = result;
        return this;
    }

    public Result() {
    }

    public static Result build(ConstantEnum e){ // 构造返回值
        Result result = new Result();
        result.setCode(e.getCode());
        result.setMessage(e.getMessage());
        return result;
    }

    public Result(Integer code, String message, T result) {
        this.code = code;
        this.message = message;
        this.result = result;
    }


    public Result(Integer code, String message, T result, T rows) {
        this.code = code;
        this.message = message;
        this.result = result;
        this.rows = rows;
    }

    public T getRows() {
        return rows;
    }

    public Result setRows(T rows) {
        this.rows = rows;
        return this;
    }

    public Result(Integer code, String message, T result, T rows, Long total) {
        this.code = code;
        this.message = message;
        this.result = result;
        this.rows = rows;
        this.total = total;
    }

    public Long getTotal() {
        return total;
    }

    public Result setTotal(Long total) {
        this.total = total;
        return this;
    }
}
